fn main() {
    // 1. 定义结构体
    #[derive(Debug)]
    struct User{
        name: String,
        count: String,
        nonce: u64,
        _active: bool, //active 关键字
    }

    // 2. 创建结构体实例
    let xiaoming = User{
        name: String::from("xiaoming"),
        count: String::from("84453448"),
        nonce: 10000,
        _active: true,
    };

    println!("{}",xiaoming.name);

    // 3. 修改结构体字段
    let mut xiaogao = User{
        name: String::from("xiaoming"),
        count: String::from("84453448"),
        nonce: 10000,
        _active: true,
    };
    xiaogao.nonce = 20000;

    // 4. 参数名字和字段名字同名的简写方法
    let name = String::from("xiaotan");
    let count = String::from("122465");
    let nonce = 10000;
    let _active = false;

    let xiaotan = User{
        name,
        count,
        nonce,
        _active,
    };

    // 5. 从其他结构体创建实例
    let xiaoyan = User{
      name: String::from("xiaoyan"),
        ..xiaotan
    };

    println!("xiaoyan.name = {}", xiaoyan.name);
    println!("xiaoyan.count = {}", xiaoyan.count);

    // 6. 元组结构体
        //字段没有名字
        //用圆括号包裹
    struct Point(i32,i32);

    let a = Point(10,23);
    println!("a.x = {},a.y = {}",a.0,a.1);


    // 7. 没有任何字段的类单元结构体
    //struct A{};

    // 8. 打印结构体
        //定义结构体时加标记: #[derive(Debug)]
    println!("xiaoming1 = {:?}",xiaoming);
    println!("xiaoming2 = {:#?}",xiaoming);

    println!("Hello, world!");
}
